<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../../css/aui.css">
    <link rel="stylesheet" type="text/css" href="../../css/aui-slide.css">
    <link rel="stylesheet" type="text/css" href="../../css/api.css">
    <script type="text/javascript" src="../../script/api.js"></script>
</head>

<body>
    <header id="header" class="aui-bar aui-bar-nav aui-bar-pink">
        <a href="" class="aui-pull-left"><span class="aui-iconfont aui-icon-left" onclick="api.closeWin()"></span></a>
        <div class="aui-title">我的粉丝</div>
        <a class="aui-pull-right aui-btn aui-btn-outlined">
            <span class="aui-iconfont aui-icon-gear"></span>
        </a>
    </header>
    <section class="aui-content-padded" id="newFANS">
    </section>
</body>
<script type="text/javascript">
    apiready = function() {
        var newFansList = $api.byId('newFansList');
        var body = {
            token: $api.getStorage('token')
        };
        useAJAX();
        window.change = function() {
            var body = {
                token: $api.getStorage('token'),
                username: data.post_username
            }
            api.ajax({
                url: 'http://www.mk517.com/webApi/change.php',
                method: 'post',
                dataType: 'json',
                "headers": {
                    "Content-Type": "application/json"
                },
                data: {
                    body: body
                }
            }, function(ret, err) {
                if (ret) {
                    ret.status ? data.status + 1 : data.status;
                    // alert(JSON.stringify(ret));
                } else {
                    // alert(JSON.stringify(err));
                }
            });

        }


        function useAJAX() {
            api.ajax({
                url: 'http://www.mk517.com/webApi/newFansList.php',
                method: 'post',
                dataType: 'json',
                "headers": {
                    "Content-Type": "application/json"
                },
                data: {
                    body: body
                }
            }, function(ret, err) {
                if (ret) {
                    for (var i = 0; i < ret.length; i++) {
                        data = ret[i];
                        $api.byId('newFANS').innerHTML += '<div class="aui-content aui-margin-b-15">' +
                            '<ul class="aui-list aui-media-list">' +
                            '<li class="aui-list-item aui-list-item-middle">' +
                            '<div class="aui-media-list-item-inner">' +
                            '<div class="aui-list-item-media" style="width: 3rem;">' +
                            '<img src="' + data.fan_avatar + '" class="aui-img-round aui-list-img-sm">' +
                            '</div>' +
                            '<div class="aui-list-item-inner">' +
                            '<div class="aui-list-item-text">' +
                            '<div class="aui-list-item-title aui-font-size-14">' + data.fan_name + '</div>' +
                            '<div class="aui-btn aui-btn-warning aui-pull-right" onclick="change();">' + (data.status % 2 == 0 ? data.status = '关注' : data.status = "已关注") + '</div>' +
                            '</div>' +
                            '<div class="aui-list-item-text">关注&nbsp;' + data.fanguan + '&nbsp;粉丝&nbsp;' + data.fancount + '</div></div></div></li></ul></div>';
                    }

                    // alert(JSON.stringify(ret));
                } else {
                    // alert(JSON.stringify(err));
                }
            });
        }


    }
</script>

</html>
